package ch.elektroplan.cmueller.logikModulGenerator.presentation.subs;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JPanel;

import ch.elektroplan.cmueller.logikModulGenerator.business.LogikModul;
import ch.elektroplan.cmueller.logikModulGenerator.business.elements.Formel;
import ch.elektroplan.cmueller.logikModulGenerator.business.elements.HS_Information;
import ch.elektroplan.cmueller.logikModulGenerator.business.elements.Input;
import ch.elektroplan.cmueller.logikModulGenerator.business.elements.MemoryVariable;
import ch.elektroplan.cmueller.logikModulGenerator.business.elements.Output;

public class GenerateButtopPanel extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	JButton generateButton = new JButton("Generate");
	ArrayList<Input> inputs;
	ArrayList<Output> outputs;
	ArrayList<MemoryVariable> memoryVariables;
	HS_Information hs_Information;
	Formel formel;

	public GenerateButtopPanel(ArrayList<Input> inputs,
			ArrayList<Output> outputs,
			ArrayList<MemoryVariable> memoryVariables,
			HS_Information hs_Information, Formel formel) {

		this.inputs = inputs;
		this.outputs = outputs;
		this.memoryVariables = memoryVariables;
		this.hs_Information = hs_Information;
		this.formel = formel;

		this.generateButton.addActionListener(new testButtonlistener());
		this.add(generateButton, BorderLayout.EAST);
	}

	private class testButtonlistener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent e) {

			LogikModul logikModul = new LogikModul(inputs, outputs, memoryVariables, hs_Information, null);
			JFileChooser fc = new  JFileChooser();
			fc.showOpenDialog(GenerateButtopPanel.this);
			logikModul.generateLM(fc.getSelectedFile());
		}
	}

}
